<?php

namespace app\timeapi\controller;

use app\common\timebusiness\Quicklogin as quickloginBn;
use app\common\timebusiness\User as userBn;

class Quicklogin extends \app\common\controller\HomeBase {

    /**
     * 小程序登录
     */
    public function wxxcxlogin() {
        try {
            $post = input();
//            $post = '{"errMsg":"getUserInfo:ok","rawData":"{\"nickName\":\"别天神\",\"gender\":1,\"language\":\"zh_CN\",\"city\":\"Quanzhou\",\"province\":\"Fujian\",\"country\":\"China\",\"avatarUrl\":\"https://wx.qlogo.cn/mmopen/vi_32/PiajxSqBRaEJT3DAxvEw3JIGRzDcuoiaMd5Kfwf0sd5uNoSCtgW2j30BJKGMn8K90Pg5AWLwovv2TiaF8On2ohSkA/132\"}","userInfo":{"nickName":"别天神","gender":1,"language":"zh_CN","city":"Quanzhou","province":"Fujian","country":"China","avatarUrl":"https://wx.qlogo.cn/mmopen/vi_32/PiajxSqBRaEJT3DAxvEw3JIGRzDcuoiaMd5Kfwf0sd5uNoSCtgW2j30BJKGMn8K90Pg5AWLwovv2TiaF8On2ohSkA/132"},"signature":"4b849b788c5143dccd0acf138ccdbb446a18b92a","encryptedData":"xPdfnqYuO9z6ZkNO5lMj6tLps+fOnsPyEpnjvDL4RqymjBG7NMlrBf2W8UI0I+o6MwBwtYwPEUSBPD9wNOXHvgrKUigkhG2PiBB3HvCodzBS5qkWoMUystKlIbUkTlhkB3x2GKOisEgIOpSvYDgmtCJr+Yz2TYs+ANiSPmkF4lKdKO5BZl5jHEa4G5973cZ8Th1bEaIyFT0d3S/cu5DDKQA10DR9SfAeQfhFItjLXkSDByG6ogH3bD1BCBDswn4ig2J5do3F+wKS0h90o0IWAoM15Do8ULUM12Vv/+Hyhbyug0/njxd8an44gnJ1zVDPo7MW6F3UH2MRzzplT9XSEcaoDebvpbFWQqWul662KfrTMfXndtKu5/16GsWhnOis6jT7ZwTirB2f9vjmJJLsqZz1hAOdKxDBeOX54MRWbcqlAqnDCYHlfsDBMzgvGI810mB6r2OR4kC1gp3yZc8o9+i5omR4VdW27g8ZzUl142OSVRwT9WikGTl3jVADtaKex6e9StmvM5dUizVqqSv0Iw==","iv":"NMtRB5noQ8t+Vjsu1yLvag==","code":"081DcajF0bbgIj2N2xkF0BhQiF0Dcajy"}';
//            $post = json_decode($post, true);
            if (!isset($post['code'])) {
                exception('登录失败', 110038);
            }
           
            $postdata = quickloginBn::checkWxXCX($post);
            //$post = $this->validate($post, 'QuickLogin.savequicklogin');
            $data = quickloginBn::savequicklogin($postdata);
            $this->_echoSuccessMessage('登陆成功', $data);
        } catch (\Exception $e) {
            $this->_echoErrorMessage($e->getMessage(), $e->getCode());
        }
    }

}
